# Maintainer: Dekedro <dekedro@protonmail.com>
pkgname=ddcci-driver-linux-src
_modname=ddcci-driver-linux
pkgver=0.4.5
pkgrel=0
pkgdesc="Linux kernel drivers for DDC/CI monitors (sources, AKMS)"
url="https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/"
arch="noarch"
license="GPL-2.0-or-later"
depends="akms"
options="!check" # no tests
source="$_modname-$pkgver.tar.gz::https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux/-/archive/v$pkgver/ddcci-driver-linux-v$pkgver.tar.gz"
builddir="$srcdir/$_modname-v$pkgver"

prepare() {
	default_prepare

	cat > AKMBUILD <<- EOF
		modname=$_modname
		modver=$pkgver-r$pkgrel
	EOF
	cat >> AKMBUILD <<- 'EOF'
		built_modules='ddcci/ddcci.ko ddcci-backlight/ddcci-backlight.ko'

		build() {
		 	make ${MAKEFLAGS:-} -C "$kernel_srcdir" M="$builddir/ddcci" src="$srcdir/ddcci"
		 	make ${MAKEFLAGS:-} -C "$kernel_srcdir" M="$builddir/ddcci-backlight" src="$srcdir/ddcci-backlight" KBUILD_EXTRA_SYMBOLS="$builddir/ddcci/Module.symvers"
		}
	EOF
}

package() {
	install -D -m644 -t "$pkgdir/usr/src/$_modname-$pkgver" AKMBUILD
	cp -a ddcci ddcci-backlight include "$pkgdir/usr/src/$_modname-$pkgver/"
}

sha512sums="
ad691e868f8123f1566a930e44e0eaafb43641a567b40163af0f15ee7baf528b8190318ad89d08a85d703ebc6f10f58fe2d9ed3f270b0ce1033535c39aa3c69a  ddcci-driver-linux-0.4.5.tar.gz
"
